<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use Think\Controller;

/**
 * 前台公共控制器
 * 为防止多分组Controller名称冲突，公共Controller名称统一使用分组名称
 */
class HomeController extends Controller {

	/* 空操作，用于输出404页面 */
	public function _empty(){
		$this->redirect('Index/index');
	}


    protected function _initialize(){
        /* 读取站点配置 */
        $config = api('Config/lists');
        C($config); //添加配置
        $this->message();
        if(!C('WEB_SITE_CLOSE')){
            $this->error('站点已经关闭，请稍后访问~');
        }
    }
    /*网站基本信息、友情链接*/
    public function message(){
        $config_set=M("config_set");
        $config_set_info=$config_set->where("`id`=1")->find();
        $this->assign("config_set_info",$config_set_info);
        //print_r($config_set_info);exit;
        $document=D("document");
        $document_banner=M("document_banner");
        $friend_data=$document->lists(42);
        foreach($friend_data as $key=>$val){
            $friend_data[$key]['links']=$document_banner->where("`id`=".$val['id'])->getField("links");
        }
        $this->assign("friend_data",$friend_data);
    }

	/* 用户登录检测 */
	protected function login(){
		/* 用户登录检测 */
		is_login() || $this->error('您还没有登录，请先登录！', U('User/login'));
	}

}
